/*
 * Copyright:  2018 smarabbit studio.
 *
 *  Licensed under the Confluent Community License; you may not use this file
 *  except in compliance with the License.  You may obtain a copy of the License at
 *
 *  http://www.confluent.io/confluent-community-license
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 *  WARRANTIES OF ANY KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations under the License.
 *
 *  @作   者： 黄开晖 (117227773@qq.com)
 *  @日   期:  2019年1月7日
 */

package com.massyframework.beanskin.runtime.service.crypto;

import java.math.BigInteger;
import java.security.interfaces.RSAPublicKey;

final class BCRSAPublicKey implements RSAPublicKey {

    /**
	 * 
	 */
	private static final long serialVersionUID = -2590765058707562718L;
	private org.bouncycastle.asn1.pkcs.RSAPublicKey target;

    /**
     * 构造方法
     * @param target
     */
    public BCRSAPublicKey(org.bouncycastle.asn1.pkcs.RSAPublicKey target) {
        this.target = target;
    }

    /**
     * Returns the public exponent.
     *
     * @return the public exponent
     */
    @Override
    public BigInteger getPublicExponent() {
        return target.getPublicExponent();
    }

    /**
     * Returns the standard algorithm name for this key. For
     * example, "DSA" would indicate that this key is a DSA key.
     * See Appendix A in the <a href=
     * "../../../technotes/guides/security/crypto/CryptoSpec.html#AppA">
     * Java Cryptography Architecture API Specification &amp; Reference </a>
     * for information about standard algorithm names.
     *
     * @return the name of the algorithm associated with this key.
     */
    @Override
    public String getAlgorithm() {
        return "RSA";
    }

    /**
     * Returns the name of the primary encoding format of this key,
     * or null if this key does not support encoding.
     * The primary encoding format is
     * named in terms of the appropriate ASN.1 data format, if an
     * ASN.1 specification for this key exists.
     * For example, the name of the ASN.1 data format for public
     * keys is <I>SubjectPublicKeyInfo</I>, as
     * defined by the X.509 standard; in this case, the returned format is
     * {@code "X.509"}. Similarly,
     * the name of the ASN.1 data format for private keys is
     * <I>PrivateKeyInfo</I>,
     * as defined by the PKCS #8 standard; in this case, the returned format is
     * {@code "PKCS#8"}.
     *
     * @return the primary encoding format of the key.
     */
    @Override
    public String getFormat() {
        return null;
    }

    /**
     * Returns the key in its primary encoding format, or null
     * if this key does not support encoding.
     *
     * @return the encoded key, or null if the key does not support
     * encoding.
     */
    @Override
    public byte[] getEncoded() {
        return new byte[0];
    }

    /**
     * Returns the modulus.
     *
     * @return the modulus
     */
    @Override
    public BigInteger getModulus() {
        return target.getModulus();
    }
}
